#import "JVPharosRootModel.h"
#import "ALUtils.h"
@implementation JVPharosRootModel

- (instancetype)initWith:(NSString *)type domain:(NSString *)domain{
    self = [super init];
    if (self) {
        self.type = type;
        self.domain = domain;
    }
    return self;
}

- (NSString *)commandId{
    return self.domain?:@"";
}

- (NSDictionary *)fieldEvent{
    // 子类实现
    return nil;
}

- (NSDictionary *)fieldTransaction{
    // 子类实现
    return nil;
}

- (NSDictionary *)pharosModeToDic{
//    NSDate *currentDate = [[LFSynchronizer instance] checkedTime];
//TODO: 需要服务器时间同步，不能完全使用客户端时间
    NSDate* currentDate =[NSDate date];
    NSString* t = [ALDateUtils iso8601DateString:currentDate];
    
//    NSTimeInterval t = (uint64_t)([currentDate timeIntervalSince1970]*NSEC_PER_USEC);
    NSMutableDictionary *pharosModel_dic = [NSMutableDictionary new];
    NSString *mode = @"native";
    
    if (self.m == 2) {
        mode = @"H5";
    }
    pharosModel_dic = @{@"type":self.type?:@"",
                        @"t":t?:@"",
                        @"do":self.domain?:@"",
                        @"m":mode?:@"",
                        @"np":@"",
                        @"d":self.d?:@"",
                        @"rid":self.rid?:@""
                        }.mutableCopy;
    
    NSDictionary *fieldEvent = [self fieldEvent];
    if (fieldEvent != nil && [fieldEvent isKindOfClass:[NSDictionary class]]) {
        [pharosModel_dic setValue:fieldEvent forKey:@"fe"];
    }
    
    NSDictionary *fieldTransaction = [self fieldTransaction];
    if (fieldTransaction != nil && [fieldTransaction isKindOfClass:[NSDictionary class]]) {
        [pharosModel_dic setValue:fieldTransaction forKey:@"ft"];
    }
    
    return pharosModel_dic;
}


@end
